/*var draw=new drawSvgFigure(svgId);
 * 画矩形draw.drawRect()
 * 画线var line=draw.drawLine()
 * 画带箭头的线draw.drawArrowLine()
 * 画文本draw.drawText()
 * 修改样式用line.attr({stroke:'red'})
 * */

var drawSvgFigure=function(svgId){
	var svgObj=this;
	var svg=Snap(svgId);
	this.drag=function(){
		if(svg !=null){
			svg.drag();
		}
	};
	var color="#00acd6";
	this.drawRect=function(x,y,w,h,rx,ry){
		return svg.paper.rect(x,y,w,h,rx,ry).attr({
			fill:color
		});
	};
	this.drawLine=function(sx,sy,ex,ey){
		return svg.paper.line(sx,sy,ex,ey).attr({
			strokeWidth:1,
			stroke:color
		});
	};
	this.drawArrowLine=function(sx,sy,ex,ey){
		var m1=svgObj.drawArrow().attr({
			"fill": color
		});
		return svg.paper.line(sx,sy,ex,ey).attr({
			 strokeWidth:1,
		     stroke:color,
			"marker-end":m1
		});
	};
	this.drawArrow=function(){
		return svg.paper.path("M2,2 L2,11 L10,6 L2,2").marker(0,0,13,13,2,6);
	}
	
	this.drawText=function(x,y,text){
		return svg.paper.text(x,y,text).attr({
			"font-size":"14px",
			"fill":"white"
		});
	};
	this.drawCircle=function(cx,cy,r){
		return svg.paper.circle(cx,cy,r).attr({
			"fill":"green"
		});
	};
	this.setGroup=function(){
		if(svg !=null){
			return svg.paper.g();
		}
	};
	this.translate=function(x,y){
		var m = new Snap.Matrix();
	    m.translate(x,y);
	    return m;
	};
};